<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/aptitude.css')}}">
    <script src="{{mix('/js/web/frame/jedate/jquery.jedate.js')}}"></script>
    <link rel="stylesheet" href="{{mix('/js/web/frame/jedate/skin/jedate.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>

@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
      @include('web.layout.seller_nav')
      <div class="right fr">
        <div class="marryreal">
          <div class="line_title">
            资质管理
          </div>
          <div class="marryst">
            <form action="{{URL::current()}}" method="get">
                <a href="/member/seller/aptitude/add" class="">发布资质</a>
                <div class="fr">
                    <span>资质名称</span>
                    <input type="text" name="aptitude_name" class="aptitude_name" id="aptitude_name" placeholder="请输入资质名称" value="">
                    <span style="margin-left: 18px;">状态</span>
                    <select name="is_for_sale" class="is_for_sale">
                        <option value="">请选择</option>
                        <option value="1">已上架</option>
                        <option value="2">已下架</option>
                        <option value="3">强制下架</option>
                    </select>
                    <input type="submit" class="buttonn" value="查询">
                </div>
            </form>
          </div>
          <div style="display:none">
          <input type="hidden" name="_scfs" value="ca350fa4d74c3b6d1640990f75488f06"/>
          </div>
          <div class="conttent">
            <div>
                <label><input type="checkbox" name="checkboxall" id="allxz">全选</label>
                <input type="submit" class="shelves do-curd" data-action="do-onsale" value="上架">
                <input type="submit" class="shelves do-curd" data-action="do-offsale" value="下架">
                <input type="submit" class="shelves do-curd" data-action="do-delete" value="删除">

            </div>
          </div>
          <div class="table list">
              <table>
                  <thead>
                  <tr>
                      <th style="border-right: 0;" width="40"></th>
                      <th style="border-left: 0;" width="200">资质名称</th>
                      <th>级别</th>
                      <th width="200">状态</th>
                      <th width="200">更新时间</th>
                      <th width="120">操作</th>
                  </tr>
                  </thead>
                  <tbody>
                      <tr>
                          <td style="border-right: 0;"><input type="checkbox" name="id[]" value="1"></td>
                          <td style="border-left: 0;">软件集成资质与服务</td>
                          <td>一级</td>
                          <td>强制下架</td><!-- 强制下架服务不可上架 -->
                          <td>06/16 15:25</td>
                          <td>
                              <a class="edit" href="/member/seller/aptitude/edit">编辑</a><br>
                              <a class="del" data-id="1">删除</a>
                          </td>
                      </tr>
                      <tr>
                          <td style="border-right: 0;"><input type="checkbox" name="id[]" value="1"></td>
                          <td style="border-left: 0;">软件集成资质与服务</td>
                          <td>一级</td>
                          <td>已下架</td>
                          <td>06/16 15:25</td>
                          <td>
                              <a class="edit" href="/member/seller/aptitude/edit">编辑</a><br>
                              <a class="del" data-id="1">删除</a>
                          </td>
                      </tr>
                      <tr>
                          <td style="border-right: 0;"><input type="checkbox" name="id[]" value="1"></td>
                          <td style="border-left: 0;">软件集成资质与服务</td>
                          <td>一级</td>
                          <td>已上架</td>
                          <td>06/16 15:25</td>
                          <td>
                              <a class="edit" href="/member/seller/aptitude/edit">编辑</a><br>
                              <a class="del" data-id="1">删除</a>
                          </td>
                      </tr>
                  </tbody>
              </table>
          </div>
            <div class="page">
                include('web.common.paginate')
            </div>
        </div>
      </div>
    </div>

</div>
@include('web.layout.footer')
<script type="text/javascript">

    $(function(){
        $("#allxz").click(function(){
            //全选 反选
            if (this.checked==true) {
                $(".marryreal .list  input:checkbox").prop("checked", true);
            }else{
                $(".marryreal .list  input:checkbox").prop("checked", false);
            }
        })
        $(".marryreal .list  input:checkbox").click(function(){
            if($(".marryreal .list  input:checkbox:checked").length == $(".marryreal .list  input:checkbox").length){
                $("#allxz").prop("checked", true);
            }else{
                $("#allxz").prop("checked", '');
            }
        })
    })


  function doAction(params,url){
      $.ajax({
          url: url,
          type: 'post',
          dataType: 'json',
          data: params,
          success:function (data) {
              if (data.code == 0) {
                layer.alert('已提交成功',{
                    icon: 1
                },function () {
                    location.reload();
                });
              }else{
                  layer.alert('操作失败',{icon: 1});
              }
          }
      })
  }
  //上架
  $('.do-curd').click(function(){
      var ids = [];
      var url = '',param = {_token:'{{csrf_token()}}'};
      var message = '';
      $(".marryreal .list  input:checked").each(function(i,n){
         ids.push(parseInt($(n).val()))
      });
      if(ids.length == 0){
          layer.alert('请先勾选资质',{icon: 2});
          return false;
      }
      param.ids = ids;
      switch($(this).data('action')){
          case 'do-delete':
              url = "";
              message = '删除';
              break;
          case 'do-onsale':
              url ="";
              message = '上架';
              param.is_sale = 1;
              break;
          case 'do-offsale':
              url ="";
              message = '下架';
              param.is_sale = 0;
              break;
      }

      // 增加操作前提示
      layer.alert('确认'+message+'该商品吗？',{
          icon: 1
      },function (index) {
          doAction(param,url);
      });
  });
</script>
</body>
</html>